/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class Demo3 {
    public static void main(String[] args) {
        Object locker =new Object();
        Thread t1 =new Thread(()->{

            synchronized (locker){
                System.out.println("t1等待过程中");
                try {
                    locker.wait();
                    System.out.println("t1等待完成");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        Thread t2 =new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (locker){
               System.out.println("尝试唤醒t1");
               locker.notify();
               System.out.println("唤醒成功");
           }
        });
        t1.start();
        t2.start();
    }
}
